#!/bin/bash

if [ "$TRAVIS_OS_NAME" == "linux" ]; then
    ls
    cd  lib
    ls
    echo "Compile HDF5 Source"
    tar xzvf hdf5-1.10.5.tar.gz
    ls
    cd hdf5-1.10.5
    ls
    echo "C_COMPILER is $C_COMPILER"
    echo "CXX_COMPILER is $CXX_COMPILER"
    mkdir build
    cd build
    pwd
    ls
    echo "TRAVIS_BUILD_DIR is $TRAVIS_BUILD_DIR"
    echo "source is $TRAVIS_BUILD_DIR/lib/hdf5-1.10.5"
    echo "build is $TRAVIS_BUILD_DIR/lib/hdf5-1.10.5/build"
    export PATH=/usr/bin/:$PATH 
    cmake --version
    cmake --help
    #cmake -G "Unix Makefiles"  \
    #      -DCMAKE_C_COMPILER=$C_COMPILER -DCMAKE_CXX_COMPILER=$CXX_COMPILER \
    #      -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX=/usr/local/HDF_Group/HDF5/1.10.5 ..
    #/usr/local/cmake-3.14.4/bin/cmake --version
    #/usr/local/cmake-3.14.4/bin/cmake -G "Unix Makefiles"  \
    cmake -G "Unix Makefiles"  \
          -DCMAKE_C_COMPILER=$C_COMPILER -DCMAKE_CXX_COMPILER=$CXX_COMPILER \
          -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX=/usr/local/HDF_Group/HDF5/1.10.5 ..

    echo "----------------------------------------"
    make -j 8
    sudo make install
    export HDF5_DIR=/usr/local/HDF_Group/HDF5/1.10.5/share/cmake
    source ~/.bashrc
    echo "printenv HDF5_DIR"
    printenv HDF5_DIR
    echo "HDF5_DIR is " $HDF5_DIR
    ls /usr/local
fi
